#include "link_list.h"

Stu_t h[100] =
    {
        {.id = 1, .age = 18, .sco = 99, .sex = "男", .name = "唐三"},
        {.id = 2, .age = 18, .sco = 99, .sex = "男", .name = "萧炎"},
        {.id = 3, .age = 18, .sco = 99, .sex = "男", .name = "叶晨"},
        {.id = 4, .age = 18, .sco = 99, .sex = "女", .name = "小舞"},
        {.id = 5, .age = 18, .sco = 99, .sex = "女", .name = "萧熏儿"},
        {.id = 6, .age = 18, .sco = 99, .sex = "女", .name = "柳如烟"},
};

int main(int argc, char const *argv[])
{
    char name1[128] = {"萧炎"};
    char pws1[128] = {"萧炎"};
    char name2[128] = {"HQYJ"};
    char pws2[128] = {"HQYJ"};
    char myname[128] = "";
    char mypws[128] = "";
    int num = 0;
    int flag1 = 1;
    int flag2 = 1;
    int num2 = 0;
    int num1 = 0;
    Link_list *L = init_link_list();
    Link_list *N = NULL;
    while (flag1)
    {
        printf("请输入用户名\n");
        scanf("%s", myname);
        if (!strcmp(myname, name1))
        {
            printf("此为学生系统，请输入密码\n");
            scanf("%s", mypws);
            if (!strcmp(mypws, pws1))
            {
                printf("密码正确\n");
                printf_Link_List(L);
            }
            else
            {
                printf("密码错误\n");
                return 0;
            }
        }
        else if (!strcmp(myname, name2))
        {
            printf("此为教师系统，请输入密码\n");
            scanf("%s", mypws);
            if (!strcmp(pws2, mypws))
            {
                while (flag2)
                {
                    printf("成功进入教师系统，输入1增加学生信息，输入2删除学生信息，输入3查找学生信息并打印，输入5查看学生信息，输入6返回登录界面，输入7退出系统\n");
                    scanf("%d", &num);
                    switch (num)
                    {
                    case 1:
                        Insert_Node(L, h[0], 0);
                        Insert_Node(L, h[1], 1);
                        Insert_Node(L, h[2], 2);
                        Insert_Node(L, h[3], 3);
                        Insert_Node(L, h[4], 4);
                        printf("请输入要插入的位置和要插入的是第几个数据\n");
                        scanf("%d", &num1);
                        scanf("%d", &num2);
                        Insert_Node(L, h[num1], num2);
                        break;
                    case 2:
                        printf("请输入要删除的id\n");
                        scanf("%d", &num1);
                        Delete_Node(L, num1);
                        break;
                    case 3:
                        printf("请输入要查找的id\n");
                        scanf("%d", &num1);
                        N = Find_Node(L, num1);
                        printf_Link_List(N);
                        break;
                    case 5:
                        printf_Link_List(L);
                        break;
                    case 6:
                        flag1 = 0;
                        flag2 = 0;
                        break;
                    case 7:
                        return 0;
                        break;

                    default:
                        break;
                    }
                }
            }
        }
    }
    L = NULL;
    return 0;
}
